from xml.sax import make_parser
from xml.sax.handler import ContentHandler

class SaxHandler(ContentHandler):
        """ Callback class for SAX parser """
	setdict = {}
        chars = ""
        current_element = None
	
	def __init__(self):
		self.setdict = {}
		self.chars = ""
		self.current_element = None

        def startElement(self,name,attrs):
                """ Handle for element begin """
                if name == "p":
                        propname = attrs.get('name')
                        self.current_element = propname

        def endElement(self,name):
                """ Handle for finished element """
                if (not self.current_element=="") :
                        self.setdict[self.current_element] = self.chars
                self.chars = ""
                self.current_element = ""

        def characters (self,ch):
                """ Handle for character data """
                sch = ch.lstrip()
                if not sch == "":
                        self.chars = sch

